﻿using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using Taype.Trading.BTC.Utilities;

namespace Taype.Trading.BTC.TradeHillAPIClient.JSONObjects
{
    
    /// <summary>
    /// Return: Dictionary containing an 'orders' array. The orders array contains dictionaries with the following fields:
    /// type: 1 for Sell order; 2 for Buy order.
    /// status: Status of the order. All orders returned will have a status of 1 which means that they are active. Orders pending cancel are still considered active and will be returned in this list as active. Orders which were not accepted (invalid funds, etc) will not be returned in this list. Orders which have been successfully canceled will not be returned in this list.
    /// oid: The unique order id.
    /// symbol: The symbol of the item being bought or sold. Currently hardcoded to BTC.
    /// price: The limit price of your order. This will match the currency you are operating in. In this case, USD.
    /// amount_orig: The original amount (size) of your order.
    /// amount: The amount (size) of your order that remains to be filled. [amount = amount_orig - amount filled]
    /// reserved_amount: The amount of money reserved in order to fill this order. Includes estimated commissions.
    /// reserved_currency: The currency of the reserved money. In this case, either USD or BTC.
    /// date: The datetime this order was created.
    /// </summary>
    public class TradeHillOrder
    {

        public TradeHillOrderType type {get; set;} // 1 for Sell order; 2 for Buy order.
        public TradeHillOrderStatus status { get; set; }
        public string oid { get; set; }
        public TradeHillCurrencySymbol symbol { get; set; }
        public double price { get; set; }
        public double amount_orig { get; set; }
        public double amount { get; set; }
        public double reserved_amount { get; set; }
        public TradeHillCurrencySymbol reserved_currency { get; set; }
        public DateTime date { get; set; }
        
        public static List<TradeHillOrder> getObjects(string jsonDataStr)
        {
            throw new NotImplementedException();
            List<TradeHillOrder> tradeList = new List<TradeHillOrder>();
            string json = jsonDataStr;
            var serializer = new JavaScriptSerializer();
            serializer.RegisterConverters(new[] { new DynamicJsonConverter() });
            dynamic obj = serializer.Deserialize(json, typeof(object));
            return tradeList;
        }
    }
}
